/*     */ package eos.moe.dragoncore;
/*     */ 
/*     */ import java.awt.image.BufferedImage;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.lang.reflect.Field;
/*     */ import java.nio.ByteBuffer;
/*     */ import java.util.HashMap;
/*     */ import javax.imageio.ImageIO;
/*     */ import net.minecraft.client.Minecraft;
/*     */ import net.minecraft.client.renderer.OpenGlHelper;
/*     */ import net.minecraft.client.renderer.texture.SimpleTexture;
/*     */ import net.minecraft.client.renderer.texture.TextureManager;
/*     */ import net.minecraft.client.resources.IResource;
/*     */ import net.minecraft.client.resources.IResourceManager;
/*     */ import net.minecraft.util.ResourceLocation;
/*     */ import net.minecraftforge.fml.relauncher.Side;
/*     */ import net.minecraftforge.fml.relauncher.SideOnly;
/*     */ import org.lwjgl.opengl.GL11;
/*     */ 
/*     */ 
/*     */ 
/*     */ @SideOnly(Side.CLIENT)
/*     */ public class vv
/*     */   extends SimpleTexture
/*     */ {
/*     */   public int d;
/*     */   public int z;
/*     */   public int i;
/*     */   public ByteBuffer[] w;
/*     */   
/*     */   public vv(ResourceLocation resourceLocation) throws IOException {
/*  33 */     super(resourceLocation);
/*  34 */     this.w = new ByteBuffer[6];
/*  35 */     this.g = resourceLocation;
/*  36 */     BufferedImage bufferedImage = cp.v(resourceLocation);
/*  37 */     initBuffers(bufferedImage, resourceLocation.toString());
/*  38 */     q.put(resourceLocation, this);
/*     */   }
/*     */   
/*     */   public void initBuffers(BufferedImage bufferedImage, String str) throws IOException {
/*  42 */     this.z = bufferedImage.getWidth();
/*  43 */     this.i = bufferedImage.getHeight();
/*  44 */     if (this.i % 4.0D != 0.0D || this.z % 3.0D != 0.0D || this.i / 4 != this.z / 3) {
/*  45 */       String str1 = "The Dimensions of %s are invalid! A Cubemap image must have an exact width-to-height ratio of 3:4!";
/*  46 */       throw new IOException(String.format(str1, new Object[] { str }));
/*     */     } 
/*  48 */     this.d = this.z / 3;
/*  49 */     BufferedImage bufferedImage1 = null;
/*  50 */     for (int i = 0; i < 6; i++) {
/*  51 */       switch (i) {
/*     */         case 0:
/*  53 */           bufferedImage1 = cp.v(bufferedImage.getSubimage(2 * this.d, this.d, this.d, this.d), 90.0D);
/*     */           break;
/*     */         
/*     */         case 1:
/*  57 */           bufferedImage1 = cp.v(bufferedImage.getSubimage(0, this.d, this.d, this.d), -90.0D);
/*     */           break;
/*     */         
/*     */         case 2:
/*  61 */           bufferedImage1 = bufferedImage.getSubimage(this.d, this.d, this.d, this.d);
/*     */           break;
/*     */         
/*     */         case 3:
/*  65 */           bufferedImage1 = bufferedImage.getSubimage(this.d, 3 * this.d, this.d, this.d);
/*     */           break;
/*     */         
/*     */         case 4:
/*  69 */           bufferedImage1 = bufferedImage.getSubimage(this.d, 2 * this.d, this.d, this.d);
/*     */           break;
/*     */         
/*     */         case 5:
/*  73 */           bufferedImage1 = cp.v(bufferedImage.getSubimage(this.d, 0, this.d, this.d), 180.0D);
/*     */           break;
/*     */       } 
/*     */       
/*  77 */       ByteBuffer byteBuffer = cp.v(bufferedImage1);
/*  78 */       this.w[i] = byteBuffer;
/*  79 */       GL11.glTexImage2D(34069 + i, 0, 32856, this.d, this.d, 0, 6408, 5121, byteBuffer);
/*     */     } 
/*     */   }
/*     */   
/*     */   public static void z(ResourceLocation a) {
/*  84 */     if (Minecraft.func_71410_x() != null && !Minecraft.func_71375_t()) {
/*     */       return;
/*     */     }
/*  87 */     vv vv1 = q.get(a);
/*  88 */     if (vv1 == null) {
/*     */       try {
/*  90 */         vv1 = new vv(a);
/*     */       }
/*  92 */       catch (IOException iOException) {
/*  93 */         iOException.printStackTrace();
/*     */       } 
/*     */     }
/*  96 */     vv1.start();
/*     */   }
/*     */   
/*     */   public void newBinding() {
/* 100 */     int i = func_110552_b();
/* 101 */     GL11.glBindTexture(34067, i);
/* 102 */     for (int j = 0; j < 6; j++) {
/* 103 */       GL11.glTexImage2D(34069 + j, 0, 32856, this.d, this.d, 0, 6408, 5121, this.w[j]);
/*     */     }
/*     */   }
/*     */   
/*     */   public void start() {
/* 108 */     OpenGlHelper.func_77473_a(zr.q);
/* 109 */     GL11.glEnable(3168);
/* 110 */     GL11.glEnable(3169);
/* 111 */     GL11.glEnable(3170);
/* 112 */     GL11.glEnable(34067);
/* 113 */     GL11.glEnable(2977);
/* 114 */     for (int i = 0; i < 6; i++) {
/* 115 */       GL11.glTexImage2D(34069 + i, 0, 32856, this.d, this.d, 0, 6408, 5121, this.w[i]);
/*     */     }
/* 117 */     GL11.glPixelStorei(3317, 1);
/* 118 */     GL11.glTexGeni(8192, 9472, 34066);
/* 119 */     GL11.glTexGeni(8193, 9472, 34066);
/* 120 */     GL11.glTexGeni(8194, 9472, 34066);
/*     */   }
/*     */   
/*     */   public void end() {
/* 124 */     GL11.glPixelStorei(3317, 1);
/* 125 */     GL11.glDisable(3168);
/* 126 */     GL11.glDisable(3169);
/* 127 */     GL11.glDisable(3170);
/* 128 */     GL11.glDisable(34067);
/* 129 */     OpenGlHelper.func_77473_a(OpenGlHelper.field_77478_a);
/*     */   }
/*     */   
/*     */   public static void v(ResourceLocation a) {
/* 133 */     Field field = null;
/* 134 */     TextureManager textureManager = (Minecraft.func_71410_x()).field_71446_o;
/* 135 */     IResourceManager iResourceManager = null;
/* 136 */     IResource iResource = null;
/* 137 */     BufferedImage bufferedImage = null;
/*     */     try {
/* 139 */       field = TextureManager.class.getDeclaredField("theResourceManager");
/* 140 */       field.setAccessible(true);
/* 141 */       iResourceManager = (IResourceManager)field.get(textureManager);
/* 142 */       iResource = iResourceManager.func_110536_a(a);
/* 143 */       InputStream inputStream = iResource.func_110527_b();
/* 144 */       bufferedImage = ImageIO.read(inputStream);
/*     */     }
/* 146 */     catch (Exception exception) {
/* 147 */       exception.printStackTrace();
/*     */     } 
/* 149 */     SimpleTexture simpleTexture = new SimpleTexture(a);
/* 150 */     System.out.println(bufferedImage);
/*     */   }
/*     */   
/*     */   public String toString() {
/* 154 */     return "Cubemap(" + this.d + "x" + this.d + ";" + this.g + ")";
/*     */   }
/*     */ 
/*     */   
/* 158 */   public static HashMap<ResourceLocation, vv> q = new HashMap<>(); static {
/* 159 */     GL11.glPixelStorei(3317, 1);
/* 160 */     GL11.glTexParameteri(34067, 10242, 33071);
/* 161 */     GL11.glTexParameteri(34067, 10243, 33071);
/* 162 */     GL11.glTexParameteri(34067, 32882, 33071);
/* 163 */     GL11.glTexParameteri(34067, 10240, 9728);
/* 164 */     GL11.glTexParameteri(34067, 10241, 9729);
/*     */   }
/*     */   
/*     */   public ResourceLocation g;
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\vv.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */